home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Pascal / Utilities / Siege Watch 2.0 / setup.p < prev    next >
Encoding:
Text File  |  1994-04-23  |  15.5 KB  |  664 lines  |  [TEXT/PJMM]

  1. unit Setup;
  2. interface
  3.  
  4.     procedure GetNewPreferences;
  5.     procedure HandleMenuChoice (menuChoice: LONGINT);
  6. implementation
  7.     uses
  8.         FixMath, Utility, Sane, Globals, Script, MySpeech, Watch, Daemon;
  9.     type
  10.         PopPrivateH = ^PopPrivatePtr;
  11.         PopPrivatePtr = ^PopPrivate;
  12.         PopPrivate = record
  13.                 mHandle: MenuHandle;
  14.                 mID: integer;
  15.                 charArray: char;
  16.             end;
  17.     const
  18.         SETUP_ID = 128;
  19.         OK_BUT = 1;
  20.         CAN_BUT = 2;
  21.         HOUR_CHECK = 3;
  22.         DAY_CHECK = 4;
  23.         BITES_CHECK = 5;
  24.         TEST_BUT = 6;
  25.         VOICE_POP = 7;
  26.  
  27.         PITCH_SLIDE = 8;
  28.         WPM_SLIDE = 9;
  29.         MOD_SLIDE = 10;
  30.         VOL_SLIDE = 11;
  31.  
  32.         PITCH_TXT = 12;
  33.         WPM_TXT = 13;
  34.         MOD_TXT = 14;
  35.         VOL_TXT = 15;
  36.  
  37.         WAIT_TIME = 20;
  38.         BITE_FREQ_SLIDE = 22;
  39.  
  40.         USE_DAEMON_CHECK = 26;
  41.         KEEP_VOICE_CHECK = 27;
  42.  
  43.     var
  44.         gTrackTime: LONGINT;
  45.         gPeriod: char;
  46.         gLocalPrefs: PrefRecord;
  47.  
  48.     function SetDialogCancelItem (theDialogPtr: DialogPtr;
  49.                                     newItem: integer): OSErr;
  50.     inline
  51.         $303C, $0305, $AA68;
  52.     function SetDialogDefaultItem (theDialogPtr: DialogPtr;
  53.                                     newItem: integer): OSErr;
  54.     inline
  55.         $303C, $0304, $AA68;
  56.     procedure ActivateItem (setupDlg: DialogPtr;
  57.                                     item: integer;
  58.                                     activ: Boolean);
  59.         var
  60.             iHandle: ControlHandle;
  61.             iType: integer;
  62.             iRect: Rect;
  63.     begin
  64.         GetDItem(setupDlg, item, iType, Handle(iHandle), iRect);
  65.         if activ then
  66.             begin
  67.                 HiliteControl(iHandle, 0);
  68.             end
  69.         else
  70.             begin
  71.                 HiliteControl(iHandle, 255);
  72.             end;
  73.     end;
  74.     procedure ActivateForDaemon (setupDlg: DialogPtr;
  75.                                     activ: Boolean);
  76.     begin
  77.  
  78.         ActivateItem(setupDlg, VOICE_POP, activ);
  79.         ActivateItem(setupDlg, PITCH_SLIDE, activ);
  80.         ActivateItem(setupDlg, WPM_SLIDE, activ);
  81.         ActivateItem(setupDlg, MOD_SLIDE, activ);
  82.         ActivateItem(setupDlg, VOL_SLIDE, activ);
  83.         ActivateItem(setupDlg, KEEP_VOICE_CHECK, activ);
  84.     end;
  85.     procedure MapValue2Fixed (ctlH: ControlHandle;
  86.                                     value: integer;
  87.                                     item: integer;
  88.                                     var fixedValue: Fixed);
  89.         var
  90.             max: extended;
  91.             min: extended;
  92.             minFloat: extended;
  93.             maxFloat: extended;
  94.             result: extended;
  95.     begin
  96.         max := GetCtlMax(ctlH);
  97.         min := GetCtlMin(ctlH);
  98.         case item of
  99.             PITCH_TXT: 
  100.                 begin
  101.                     minFloat := MIN_PITCH;
  102.                     maxFloat := MAX_PITCH;
  103.                 end;
  104.             VOL_TXT: 
  105.                 begin
  106.                     minFloat := MIN_VOL;
  107.                     maxFloat := MAX_VOL;
  108.                 end;
  109.             MOD_TXT: 
  110.                 begin
  111.                     minFloat := MIN_MOD;
  112.                     maxFloat := MAX_MOD;
  113.                 end;
  114.             WPM_TXT: 
  115.                 begin
  116.                     maxFloat := MAX_WPM;
  117.                     minFloat := MIN_WPM;
  118.                 end;
  119.         end;
  120.  
  121.         result := minFloat + (value - min) / (max - min) * (maxFloat - minFloat);
  122.         fixedValue := X2Fix(result);
  123.     end;
  124.     procedure GetFixedString (fixedValue: Fixed;
  125.                                     var fixedString: Str255);
  126.         var
  127.             aDecForm: DecForm;
  128.             tempExtended: extended;
  129.     begin
  130.         tempExtended := Fix2X(fixedValue);
  131.         aDecForm.style := FixedDecimal;
  132.         aDecForm.digits := 2;
  133.         num2str(aDecForm, tempExtended, DecStr(fixedString));
  134.     end;
  135.     procedure SetFixedTxtValue (setupDlg: DialogPtr;
  136.                                     ctlH: ControlHandle;
  137.                                     item: integer;
  138.                                     var fixedValue: Fixed);
  139.         var
  140.             iHandle: Handle;
  141.             iType: integer;
  142.             iRect: Rect;
  143.             value: integer;
  144.             fixedString: Str255;
  145.     begin
  146.         GetDItem(setupDlg, item, iType, iHandle, iRect);
  147.         value := GetCtlValue(ctlH);
  148.         MapValue2Fixed(ctlH, value, item, fixedValue);
  149.         GetFixedString(fixedValue, fixedString);
  150.         SetIText(iHandle, fixedString);
  151.     end; (* end SetFixedTxtValue *)
  152.  
  153.     function MapFixed2Value (slideH: ControlHandle;
  154.                                     item: integer;
  155.                                     fixedValue: Fixed): integer;
  156.         var
  157.             min: extended;
  158.             max: extended;
  159.             minFloat: extended;
  160.             maxFloat: extended;
  161.             valFloat: extended;
  162.     begin
  163.         case item of
  164.             PITCH_SLIDE: 
  165.                 begin
  166.                     minFloat := MIN_PITCH;
  167.                     maxFloat := MAX_PITCH;
  168.                 end;
  169.             WPM_SLIDE: 
  170.                 begin
  171.                     minFloat := MIN_WPM;
  172.                     maxFloat := MAX_WPM;
  173.                 end;
  174.             VOL_SLIDE: 
  175.                 begin
  176.                     minFloat := MIN_VOL;
  177.                     maxFloat := MAX_VOL;
  178.                 end;
  179.             MOD_SLIDE: 
  180.                 begin
  181.                     minFloat := MIN_MOD;
  182.                     maxFloat := MAX_MOD;
  183.                 end;
  184.         end;
  185.  
  186.         min := GetCtlMin(slideH);
  187.         max := GetCtlMax(slideH);
  188.         valFloat := Fix2X(fixedValue);
  189.         valFloat := min + (max - min) * ((valFloat - minFloat) / (maxFloat - minFloat));
  190.         MapFixed2Value := Num2Integer(valFloat);
  191.     end;
  192.  
  193.  
  194.     procedure SetBiteFreqValue (setupDlg: DialogPtr;
  195.                                     value: integer;
  196.                                     undimmed: Boolean);
  197.         var
  198.             biteCtl: ControlHandle;
  199.             iRect: Rect;
  200.             iType: integer;
  201.     begin
  202.         GetDItem(setupDlg, BITE_FREQ_SLIDE, iType, Handle(biteCtl), iRect);
  203.         SetCtlValue(biteCtl, value);
  204.         if undimmed = TRUE then
  205.             begin
  206.                 HiliteControl(biteCtl, 0);
  207.             end
  208.         else
  209.             begin
  210.                 HiliteControl(biteCtl, 255);
  211.             end;
  212.     end;
  213.  
  214.     function HandleNonDialogEvent (theEvent: EventRecord;
  215.                                     setupDlg: DialogPtr): integer;
  216.         var
  217.             whichWin: WindowPtr;
  218.             iWinPart: integer;
  219.             limitRect: Rect;
  220.             menuChoice: LONGINT;
  221.     begin
  222.         HandleNonDialogEvent := 0;
  223.         case theEvent.what of
  224.             updateEvt: 
  225.                 begin
  226.                     DrawControls(setupDlg);
  227.                 end;
  228.             mouseDown: 
  229.                 begin
  230.                     iWinPart := FindWindow(theEvent.where, whichWin);
  231.                     case iWinPart of
  232.                         inDesk: 
  233.                             begin
  234.                             end;
  235.                         inMenuBar: 
  236.                             begin
  237.                                 menuChoice := MenuSelect(theEvent.where);
  238.                                 HandleMenuChoice(menuChoice);
  239.                                 if gDone = TRUE then
  240.                                     HandleNonDialogEvent := 2;
  241.                             end;
  242.                         inSysWindow: 
  243.                             begin
  244.                             end;
  245.                         inDrag: 
  246.                             begin
  247.                                 SetRect(limitRect, -32768, -32768, 32767, 32767);
  248.                                 DragWindow(whichWin, theEvent.where, limitRect);
  249.  
  250.                             end;
  251.                         inContent: 
  252.                             begin
  253.                             end;
  254.                     end;
  255.                 end;
  256.             otherwise
  257.                 begin
  258.                 end;
  259.         end;
  260.  
  261.     end;
  262.     function FindTextFromControl (setupDlg: DialogPtr;
  263.                                     ctlH: ControlHandle): integer;
  264.         var
  265.             iType: integer;
  266.             iRect: Rect;
  267.             iHandle: ControlHandle;
  268.             index: integer;
  269.             result: integer;
  270.     begin
  271.         index := PITCH_SLIDE;
  272.         result := 0;
  273.         while (index <= VOL_SLIDE) and (result = 0) do { note that the bite freq. wont be found }
  274.             begin
  275.                 GetDItem(setupDlg, index, iType, Handle(iHandle), iRect);
  276.                 if iHandle = ctlH then
  277.                     begin
  278.                         result := index + 4;
  279.                     end;
  280.                 index := index + 1;
  281.             end;
  282.         FindTextFromControl := result;
  283.     end;
  284.  
  285.     procedure SetMyCtlActions (setupDlg: DialogPtr;
  286.                                     item: integer;
  287.                                     actProc: ProcPtr);
  288.         var
  289.             ctlH: ControlHandle;
  290.             iType: integer;
  291.             iRect: Rect;
  292.  
  293.     begin
  294.         GetDItem(setupDlg, item, iType, Handle(ctlH), iRect);
  295.         SetCtlAction(ctlH, actProc);
  296.     end;
  297.     function HandleDialogEvent (theEvent: EventRecord;
  298.                                     setupDlg: DialogPtr): integer;
  299.         var
  300.             whichDlog: DialogPtr;
  301.             itemHit: integer;
  302.             value: integer;
  303.             ctlH: ControlHandle;
  304.             iRect: Rect;
  305.             iType: integer;
  306.             iErr: OSErr;
  307.             locPoint: Point;
  308.             doSelect, doHandle, doCancel: Boolean;
  309.             theChar: CHAR;
  310.             charCode: integer;
  311.             tick: LONGINT;
  312.             charPtr: Ptr;
  313.             testString: Str255;
  314.     begin
  315.         HandleDialogEvent := 0;
  316.         doSelect := TRUE;
  317.         doHandle := FALSE;
  318.         doCancel := FALSE;
  319.         case theEvent.what of
  320.             mouseDown: 
  321.                 begin
  322.                     locPoint := theEvent.where;
  323.                     GlobalToLocal(locPoint);
  324.                     itemHit := FindControl(locPoint, setupDlg, ctlH);
  325.                 end;
  326.             keyDown, autoKey: 
  327.                 begin
  328.                     theChar := CHR(BitAnd(theEvent.message, charCodeMask));
  329.                     if (BitAnd(theEvent.modifiers, cmdKey) <> 0) then
  330.                         begin
  331.                             HandleMenuChoice(MenuKey(theChar));
  332.                             if (gDone) or (ORD(theChar) = 46) then
  333.                                 begin
  334.                                     HandleDialogEvent := 2;
  335.                                     doCancel := TRUE;
  336.                                 end;
  337.                             doSelect := FALSE;
  338.                         end
  339.                     else
  340.                         begin
  341.                             charPtr := @theChar;
  342.                             charCode := CharType(charPtr, 1);
  343.                             if ORD(theChar) = 13 then
  344.                                 begin
  345.                                     doSelect := FALSE;
  346.                                     GetDItem(setupDlg, OK_BUT, iType, Handle(ctlH), iRect);
  347.                                     if ctlH^^.contrlHilite <> 255 then
  348.                                         begin
  349.                                             HandleDialogEvent := 1;
  350.                                             HiliteControl(ctlH, 1);
  351.                                             Delay(5, tick);
  352.                                             HiliteControl(ctlH, 1);
  353.                                         end;
  354.                                 end
  355.  
  356.                             else if ORD(theChar) = 27 then
  357.                                 begin
  358.                                     HandleDialogEvent := 2;
  359.                                     doSelect := FALSE;
  360.                                     doCancel := TRUE;
  361.                                 end
  362.                             else
  363.                                 begin
  364.                                     doSelect := FALSE;
  365.                                 end;
  366.  
  367.                         end;
  368.                 end;
  369.         end;
  370.         if doCancel then
  371.             begin
  372.                 GetDItem(setupDlg, CAN_BUT, iType, Handle(ctlH), iRect);
  373.                 HiliteControl(ctlH, 1);
  374.                 Delay(5, tick);
  375.                 HiliteControl(ctlH, 1);
  376.             end;
  377.         if doSelect then
  378.             begin
  379.                 if DialogSelect(theEvent, whichDlog, itemHit) = TRUE then
  380.                     doHandle := TRUE;
  381.             end;
  382.         if doHandle then
  383.             begin
  384.                 if whichDlog = setupDlg then
  385.                     begin
  386.                         GetDItem(setupDlg, itemHit, iType, Handle(ctlH), iRect);
  387.                         case itemHit of
  388.                             OK_BUT: 
  389.                                 begin
  390.                                     HandleDialogEvent := 1;
  391.                                 end;
  392.                             CAN_BUT: 
  393.                                 begin
  394.                                     HandleDialogEvent := 2;
  395.                                 end;
  396.                             HOUR_CHECK: 
  397.                                 begin
  398.                                     NegateCheckItem(setupDlg, HOUR_CHECK, gLocalPrefs.sayHours);
  399.                                 end;
  400.                             DAY_CHECK: 
  401.                                 begin
  402.                                     NegateCheckItem(setupDlg, DAY_CHECK, gLocalPrefs.sayDays);
  403.                                 end;
  404.                             USE_DAEMON_CHECK: 
  405.                                 begin
  406.                                     NegateCheckItem(setupDlg, USE_DAEMON_CHECK, gLocalPrefs.useDaemon);
  407.                                     ActivateForDaemon(setupDlg, gLocalPrefs.useDaemon);
  408.                                 end;
  409.                             KEEP_VOICE_CHECK: 
  410.                                 begin
  411.                                     NegateCheckItem(setupDlg, KEEP_VOICE_CHECK, gLocalPrefs.keepVoice);
  412.                                 end;
  413.                             BITES_CHECK: 
  414.                                 begin
  415.                                     NegateCheckItem(setupDlg, BITES_CHECK, gLocalPrefs.sayBites);
  416.                                     SetBiteFreqValue(setupDlg, gLocalPrefs.biteFreq, gLocalPrefs.sayBites);
  417.                                 end;
  418.                             BITE_FREQ_SLIDE: 
  419.                                 begin
  420.                                     gLocalPrefs.biteFreq := GetCtlValue(ControlHandle(ctlH));
  421.                                 end;
  422.                             PITCH_SLIDE: 
  423.                                 begin
  424.                                     SetFixedTxtValue(setupDlg, ctlH, PITCH_TXT, gLocalPrefs.pitch);
  425.                                 end;
  426.                             WPM_SLIDE: 
  427.                                 begin
  428.                                     SetFixedTxtValue(setupDlg, ctlH, WPM_TXT, gLocalPrefs.wpm);
  429.                                 end;
  430.                             VOL_SLIDE: 
  431.                                 begin
  432.                                     SetFixedTxtValue(setupDlg, ctlH, VOL_TXT, gLocalPrefs.volume);
  433.                                 end;
  434.                             MOD_SLIDE: 
  435.                                 begin
  436.                                     SetFixedTxtValue(setupDlg, ctlH, MOD_TXT, gLocalPrefs.modulation);
  437.                                 end;
  438.                             VOICE_POP: 
  439.                                 begin
  440.                                     value := GetCtlValue(ctlH);
  441.                                     iErr := GetIndVoice(value, @gLocalPrefs.voice);
  442.                                 end;
  443.                             TEST_BUT: 
  444.                                 begin
  445.                                     GetIndString(testString, 128, 3);
  446.                                     if gLocalPrefs.useDaemon then
  447.                                         begin
  448.                                             Talk2Daemon(gLocalPrefs, testString);
  449.                                         end
  450.                                     else
  451.                                         begin
  452.                                             iErr := SpeakString(testString);
  453.                                         end;
  454.                                 end;
  455.                         end;
  456.                     end;
  457.             end;
  458.     end;
  459.  
  460.  
  461.     function HandleTheSetup (setupDlg: DialogPtr): Boolean;
  462.         var
  463.             done: integer;
  464.             theEvent: EventRecord;
  465.     begin
  466.         done := 0;
  467.         while (done = 0) do
  468.             begin
  469.                 gTrackTime := TickCount;
  470.                 if (GetNextEvent(everyEvent, theEvent)) then
  471.                     begin
  472.                         if (IsDialogEvent(theEvent)) then
  473.                             begin
  474.                                 done := HandleDialogEvent(theEvent, setupDlg);
  475.                             end
  476.                         else
  477.                             begin
  478.                                 done := HandleNonDialogEvent(theEvent, setupDlg);
  479.                             end;
  480.                     end;
  481.             end;
  482.         if done = 1 then
  483.             begin
  484.                 HandleTheSetup := TRUE;
  485.             end
  486.         else
  487.             begin
  488.                 HandleTheSetup := FALSE;
  489.             end;
  490.     end;
  491.  
  492.     procedure BuildVoiceMenu (setupDlg: DialogPtr;
  493.                                     var voice: VoiceSpec);
  494.         var
  495.             numVoices: integer;
  496.             i: integer;
  497.             iErr: OSErr;
  498.             iType: integer;
  499.             iHandle: ControlHandle;
  500.             iRect: Rect;
  501.             privData: PopPrivateH;
  502.             menuH: MenuHandle;
  503.             aVoiceSpec: VoiceSpec;
  504.             info: VoiceDescription;
  505.             voiceFound: Boolean;
  506.     begin
  507.         info.length := sizeof(VoiceDescription);
  508.         info.reserved1 := 0;
  509.         info.reserved2 := 0;
  510.         info.reserved3 := 0;
  511.         info.reserved4 := 0;
  512.         GetDItem(setupDlg, VOICE_POP, iType, Handle(iHandle), iRect);
  513.         privData := PopPrivateH(iHandle^^.contrlData);
  514.         menuH := privData^^.mHandle;
  515.         iErr := CountVoices(numVoices);
  516.         if iErr = 0 then
  517.             begin
  518.                 i := 1;
  519.                 voiceFound := FALSE;
  520.                 while (i <= numVoices) and (iErr = 0) do
  521.                     begin
  522.                         iErr := GetIndVoice(i, @aVoiceSpec);
  523.                         if iErr = 0 then
  524.                             begin
  525.                                 iErr := GetVoiceDescription(@aVoiceSpec, @info, sizeof(VoiceDescription));
  526.                                 if iErr = 0 then
  527.                                     begin
  528.                                         AppendMenu(menuH, info.name);
  529.                                         if (voice.creator = aVoiceSpec.creator) and (voice.id = aVoiceSpec.id) then
  530.                                             begin
  531.                                                 voiceFound := TRUE;
  532.                                                 iHandle^^.contrlValue := i;
  533.                                             end
  534.                                         else if (i = numVoices) and (voiceFound = FALSE) then
  535.                                             begin
  536.                                                 iHandle^^.contrlValue := i;
  537.                                                 iErr := MakeVoiceSpec(aVoiceSpec.creator, aVoiceSpec.id, @voice);
  538.                                             end;
  539.                                     end;
  540.                             end;
  541.                         i := i + 1;
  542.                     end;
  543.             end;
  544.  
  545.     end;
  546.  
  547.  
  548.     procedure SetSlideValue (setupDlg: DialogPtr;
  549.                                     item: integer;
  550.                                     itemText: integer;
  551.                                     fixedValue: Fixed);
  552.         var
  553.             iType: integer;
  554.             slideH: ControlHandle;
  555.             textH: Handle;
  556.             iRect: Rect;
  557.             intValue: integer;
  558.             fixedString: Str255;
  559.     begin
  560.         GetDItem(setupDlg, item, iType, Handle(slideH), iRect);
  561.         GetDItem(setupDlg, itemText, iType, textH, iRect);
  562.         intValue := MapFixed2Value(slideH, item, fixedValue);
  563.         SetCtlValue(slideH, intValue);
  564.         GetFixedString(fixedValue, fixedString);
  565.         SetIText(textH, fixedString);
  566.     end;
  567.     procedure TrackASlide (item: integer);
  568.         var
  569.             setupDlg: DialogPtr;
  570.             newValue: Fixed;
  571.             theSlide: ControlHandle;
  572.             iRect: Rect;
  573.             iType, value: integer;
  574.             fixedString: Str255;
  575.             textH: Handle;
  576.     begin
  577.         GetPort(setupDlg);
  578.         GetDItem(setupDlg, item, iType, Handle(theSlide), iRect);
  579.         value := GetCtlValue(theSlide);
  580.         MapValue2Fixed(theSlide, value, item + 4, newValue);
  581.         GetFixedString(newValue, fixedString);
  582.         GetDItem(setupDlg, item + 4, iType, textH, iRect);
  583.         SetIText(textH, fixedString);
  584.     end;
  585.     procedure TrackPitch;
  586.     begin
  587.         TrackASlide(PITCH_SLIDE);
  588.     end;
  589.     procedure TrackRate;
  590.     begin
  591.         TrackASlide(WPM_SLIDE);
  592.     end;
  593.     procedure TrackVolume;
  594.     begin
  595.         TrackASlide(VOL_SLIDE);
  596.     end;
  597.     procedure TrackMod;
  598.     begin
  599.         TrackASlide(MOD_SLIDE);
  600.     end;
  601.  
  602.     procedure SetupTheDialog (setupDlg: DialogPtr;
  603.                                     prefs: PrefRecord);
  604.         var
  605.             hIntl: Handle;
  606.     begin
  607.         hIntl := IUGetIntl(0);
  608.         if hIntl <> nil then
  609.             gPeriod := char(hIntl^^);
  610.         HPurge(hIntl);
  611.         SetCheckItem(setupDlg, DAY_CHECK, prefs.sayDays);
  612.         SetCheckItem(setupDlg, HOUR_CHECK, prefs.sayHours);
  613.         SetCheckItem(setupDlg, BITES_CHECK, prefs.sayBites);
  614.         SetCheckItem(setupDlg, USE_DAEMON_CHECK, prefs.useDaemon);
  615.         SetCheckItem(setupDlg, KEEP_VOICE_CHECK, prefs.keepVoice);
  616.         SetBiteFreqValue(setupDlg, prefs.biteFreq, prefs.sayBites);
  617.         BuildVoiceMenu(setupDlg, prefs.voice);
  618.         SetSlideValue(setupDlg, PITCH_SLIDE, PITCH_TXT, prefs.pitch);
  619.         SetSlideValue(setupDlg, WPM_SLIDE, WPM_TXT, prefs.wpm);
  620.         SetSlideValue(setupDlg, VOL_SLIDE, VOL_TXT, prefs.volume);
  621.         SetSlideValue(setupDlg, MOD_SLIDE, MOD_TXT, prefs.modulation);
  622.         SetMyCtlActions(setupDlg, PITCH_SLIDE, @TrackPitch);
  623.         SetMyCtlActions(setupDlg, WPM_SLIDE, @TrackRate);
  624.         SetMyCtlActions(setupDlg, VOL_SLIDE, @TrackVolume);
  625.         SetMyCtlActions(setupDlg, MOD_SLIDE, @TrackMod);
  626.  
  627.         ActivateForDaemon(setupDlg, prefs.useDaemon);
  628.     end;
  629.  
  630.     procedure GetNewPreferences;
  631.         var
  632.             setupDlg: DialogPtr;
  633.             iErr: OSErr;
  634.             dummy: Boolean;
  635.     begin
  636.         BlockMove(@gPreferences, @gLocalPrefs, sizeof(PrefRecord));
  637.         setupDlg := GetNewDialog(SETUP_ID, nil, DialogPtr(-1));
  638.         if setupDlg <> nil then
  639.             DisposDialog(setupDlg);
  640.         setupDlg := GetNewDialog(SETUP_ID, nil, DialogPtr(-1));
  641.  
  642.  
  643.         if setupDlg <> nil then
  644.             begin
  645.                 SetupTheDialog(setupDlg, gLocalPrefs);
  646.                 HideWindow(gWindow);
  647.                 KillMyGWorlds;
  648.                 ShowWindow(setupDlg);
  649.                 SetPort(setupDlg);
  650.                 ClipRect(setupDlg^.portRect);
  651.                 if HandleTheSetup(setupDlg) then
  652.                     begin
  653.                         BlockMove(@gLocalPrefs, @gPreferences, sizeof(PrefRecord));
  654.                     end;
  655.                 DisposDialog(setupDlg);
  656.                 dummy := InitMyGWorlds;
  657.  
  658.                 ShowWindow(gWindow);
  659.                 SetPort(gWindow);
  660.                 SelectWindow(gWindow);
  661.                 DrawTheWatch;
  662.             end; (* use of setup dialog *)
  663.     end;
  664. end.